/**
 * @file uno.ts
 * @description uno.config.ts 配置文件
 * @see ../uno.config.ts
 */

import type { Rule } from 'unocss'

/**
 * unocss 主题颜色配置
 * @note 与 _colors.scss 保持一致
 * @see ../../styles/abstracts/_colors.scss
 */
const themeColors = {
  primary: {
    default: '#2979ff',
    light: '#5c9dff',
    dark: '#1c64d9',
  },
  text: {
    primary: '#303133',
    default: '#606266',
    secondary: '#909399',
    placeholder: '#c0c4cc',
  },
  bg: {
    default: '#ffffff',
    page: '#f5f5f5',
  },
  success: '#07c160',
  warning: '#ffb703',
  error: '#fa3534',
  info: '#909399',
} as const

/**
 * unocss 主题字体大小配置
 * @note 与 _typography.scss 保持一致
 * @see ../../styles/abstracts/_typography.scss
 */
const themeFontSize = {
  xs: ['24rpx', '1.5'], // 超小
  sm: ['28rpx', '1.5'], // 小
  md: ['32rpx', '1.5'], // 中等
  lg: ['36rpx', '1.5'], // 大
  xl: ['44rpx', '1.5'], // 特大
} as const

/**
 * unocss 主题阴影配置
 * @note 与 _shadows.scss 保持一致
 * @see ../../styles/abstracts/_shadows.scss
 */
const themeShadow = {
  xs: '0 2rpx 4rpx rgba(0, 0, 0, 0.05)',
  sm: '0 2rpx 8rpx rgba(0, 0, 0, 0.1)',
  md: '0 4rpx 16rpx rgba(0, 0, 0, 0.1)',
  lg: '0 8rpx 24rpx rgba(0, 0, 0, 0.15)',
  xl: '0 12rpx 32rpx rgba(0, 0, 0, 0.2)',
  default: '0 4rpx 16rpx rgba(0, 0, 0, 0.1)',
} as const

/**
 * unocss 主题配置
 * @see https://unocss.nodejs.cn/config/theme
 */
export const theme = {
  colors: themeColors,
  fontSize: themeFontSize,
  boxShadow: themeShadow,
} as const

/**
 * unocss 规则
 * @see https://unocss.nodejs.cn/config/rules
 */
export const rules: Rule[] = [
  ['safe-area-inset-top', { 'padding-top': 'env(safe-area-inset-top)' }],
  ['safe-area-inset-bottom', { 'padding-bottom': 'env(safe-area-inset-bottom)' }],
] as const

/**
 * unocss 快捷方式
 * @see https://unocss.nodejs.cn/config/shortcuts
 */
export const shortcuts = {
  // 布局
  'flex-row': 'flex flex-row',
  'flex-col': 'flex flex-col',

  'flex-x-start': 'flex justify-start',
  'flex-x-center': 'flex justify-center',
  'flex-x-end': 'flex justify-end',
  'flex-x-between': 'flex justify-between',
  'flex-x-around': 'flex justify-around',
  'flex-x-evenly': 'flex justify-evenly',

  'flex-y-start': 'flex items-start',
  'flex-y-center': 'flex items-center',
  'flex-y-end': 'flex items-end',
  'flex-y-between': 'flex items-between',
  'flex-y-around': 'flex items-around',
  'flex-y-evenly': 'flex items-evenly',

  'flex-x-start-y-start': 'flex justify-start items-start',
  'flex-x-start-y-center': 'flex justify-start items-center',
  'flex-x-start-y-end': 'flex justify-start items-end',
  'flex-x-start-y-between': 'flex justify-start items-between',
  'flex-x-start-y-around': 'flex justify-start items-around',
  'flex-x-start-y-evenly': 'flex justify-start items-evenly',

  'flex-x-center-y-start': 'flex justify-center items-start',
  'flex-x-center-y-center': 'flex justify-center items-center',
  'flex-x-center-y-end': 'flex justify-center items-end',
  'flex-x-center-y-between': 'flex justify-center items-between',
  'flex-x-center-y-around': 'flex justify-center items-around',
  'flex-x-center-y-evenly': 'flex justify-center items-evenly',

  'flex-x-end-y-start': 'flex justify-end items-start',
  'flex-x-end-y-center': 'flex justify-end items-center',
  'flex-x-end-y-end': 'flex justify-end items-end',
  'flex-x-end-y-between': 'flex justify-end items-between',
  'flex-x-end-y-around': 'flex justify-end items-around',
  'flex-x-end-y-evenly': 'flex justify-end items-evenly',

  'flex-x-between-y-start': 'flex justify-between items-start',
  'flex-x-between-y-center': 'flex justify-between items-center',
  'flex-x-between-y-end': 'flex justify-between items-end',
  'flex-x-between-y-between': 'flex justify-between items-between',
  'flex-x-between-y-around': 'flex justify-between items-around',
  'flex-x-between-y-evenly': 'flex justify-between items-evenly',

  'flex-x-around-y-start': 'flex justify-around items-start',
  'flex-x-around-y-center': 'flex justify-around items-center',
  'flex-x-around-y-end': 'flex justify-around items-end',
  'flex-x-around-y-between': 'flex justify-around items-between',
  'flex-x-around-y-around': 'flex justify-around items-around',
  'flex-x-around-y-evenly': 'flex justify-around items-evenly',

  'flex-x-evenly-y-start': 'flex justify-evenly items-start',
  'flex-x-evenly-y-center': 'flex justify-evenly items-center',
  'flex-x-evenly-y-end': 'flex justify-evenly items-end',
  'flex-x-evenly-y-between': 'flex justify-evenly items-between',
  'flex-x-evenly-y-around': 'flex justify-evenly items-around',
  'flex-x-evenly-y-evenly': 'flex justify-evenly items-evenly',

  // 定位
  'fixed-bottom': 'fixed bottom-0 left-0 right-0',
  'fixed-top': 'fixed top-0 left-0 right-0',

  'truncate-2':
    'overflow-hidden text-ellipsis display--webkit-box -webkit-line-clamp-2 -webkit-box-orient-vertical',
  'truncate-3':
    'overflow-hidden text-ellipsis display--webkit-box -webkit-line-clamp-3 -webkit-box-orient-vertical',

  // 组件
  card: 'bg-white rounded-md shadow-default',

  // 示例常用组合
  'section-title': 'text-md font-bold mb-20rpx',
  'demo-item': 'mb-20rpx',
} as const
